<template>
  <view
    class="search-bar"
    :class="tagsClass"
    @click="onSearch"
  >
    <van-icon
      :name="icon"
      class-prefix="csicon"
      mode="aspectFit"
    />
    <view class="search-bar-text">{{placeholder}}</view>
  </view>
</template>

<script>
export default {
  name: 'SearchBar',
  props: {
    icon: {
      type: String,
      default: 'search'
    },
    placeholder: {
      type: String,
      default: '搜索'
    }
  },
  computed: {
    tagsClass () {
      return this.separator ? 'tags-separator' : ''
    }
  },
  methods: {
    onSearch () {
      this.$emit('search')
      wx.navigateTo({
        url: '/pages/search/main'
      })
    }
  }
}
</script>

<style lang="less">
.search-bar {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 32px;
  height: 30px;
  padding: 5px 10px;
  width: 100%;
  image {
    width: 20px;
    height: 20px;
  }
  &-text {
    padding-left: 5px;
    font-size: 12px;
    line-height: 1;
  }
}
</style>
